      $ SET SOURCEFORMAT "FREE"
IDENTIFICATION DIVISION.
PROGRAM-ID.  Transactions.
AUTHOR.  Raj Akula.
* Demonstrates how to read an Indexed file sequentially
* on any of its keys

ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
   SELECT TransactionFile ASSIGN TO "transactions.dat"
          ORGANIZATION IS LINE SEQUENTIAL
          ACCESS MODE IS SEQUENTIAL.

      

DATA DIVISION.
FILE SECTION.
FD TransactionFile.
01 TransactionRecord.
   88 EndOfFile VALUE HIGH-VALUE.
   02 CustNo               PIC 9(5).
   02 Filler               PIC X(5).
   02 ProductNo            PIC X(6).
   02 Filler               PIC X(6).
   02 Quantity             PIC 9.
   02 Filler               PIC X(5).
   02 SaleCode             PIC X(1).


WORKING-STORAGE SECTION.
01   TransactionStatus              PIC X(2).
        
  
PROCEDURE DIVISION.
Begin.
   OPEN INPUT TransactionFile.

*  The READ..NEXT RECORD will read the file sequentially
*  as if it ordered on whichever key has been 
*  established as the KOR.
   READ TransactionFile NEXT RECORD 
      AT END SET EndOfFile TO TRUE
   END-READ.
   PERFORM UNTIL EndOfFile
      DISPLAY  TransactionRecord
      READ TransactionFile NEXT RECORD 
         AT END SET EndOfFile TO TRUE
      END-READ
   END-PERFORM.

   CLOSE TransactionFile.
   STOP RUN.
